using System;
using System.ServiceModel;

using NUnit.Framework;

namespace Weever.Json.Binding.Tests
{
    [TestFixture]
    public class TestService2
    {
        private ServiceHost _host;
        
        [TestFixtureSetUp]
        public void SetupService()
        {
            ServiceHost host = new ServiceHost(typeof(TestService), new Uri("http://localhost:8085"));
            host.AddServiceEndpoint(typeof (ITestServiceContract), new BasicHttpBinding(), "bla");
            host.Open();
            _host = host;
        }
        
        [TestFixtureTearDown]
        public void StopService()
        {
            if (_host != null)
                _host.Close();
        }
        
        [Test]
        public void DummyTest()
        {
            ITestServiceContract service = ChannelFactory<ITestServiceContract>.CreateChannel(new BasicHttpBinding() , 
                                                                                              new EndpointAddress("http://localhost:8085/bla"));
            using ((IDisposable)service)
                Console.WriteLine(service.DoSmth("test"));
        }
    }
}
